package com.lxhll.personnel.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@Configuration
@EnableSwaggerBootstrapUI
/**
 * Swagger地址：：：http://localhost:8082/doc.html
 */
public class SwaggerConfig {


    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //控制器类包路径
                .apis(RequestHandlerSelectors.basePackage("com.lxhll.personnel"))
                .paths(PathSelectors.any()).build();
    }


    /**自定义apiInfo
     * 构建api文档的详细信息
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 设置页面标题
                .title("人事管理系统api接口文档")
                // 设置接口描述
                .description("人事管理系统接口展示")
                // 设置版本
                .version("1.0")
                // 构建
                .build();
    }
}
